<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <script type="text/javascript" src="scripts/boot.js"></script>
    <style type="text/css">
	.item{
		width: 95px;
		display: inline-block;
		margin-left: 5px;
	}
	</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
		<table style="width:100%;">
	        <tr>
	            <td style="width:30%;">
	             	<span class="item">订单编号(精确)：</span> 
	             	<input id="serialNum" class="mini-textbox" emptyText="请输入订单编号" style="width:160px;" />&nbsp;
	            </td>
	            <td style="width:30%;"> 	
	            	<span class="item">物流公司(精确)：</span>
	            	<input id="expressId" showNullItem="true" emptyText="请选择..." nullItemText="全部" class="mini-combobox" style="width:160px;" textField="name" valueField="id" url="orders_find_logistics_view.do" allowInput="true"/>&nbsp;
	            </td>
	            <td style="width:30%;">  	
	            	<span class="item">收货人(精确)：</span> 
	            	<input id="name" class="mini-textbox" emptyText="请输入收货人" style="width:160px;" />&nbsp;
	            </td>
	        </tr>
	        <tr>
	        	<td style="width:30%;" colspan="3">
	        		<span class="item">下单时间(大于)：</span> 
	        		<input id="createTime" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false"/>
	        	</td>
	        	 <td style="white-space:nowrap;">
	                <a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
	            </td>
	        </tr>
	    </table>           
	</div>
	 <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:100%;">
	        <tr>
	       	 	<td style="width:100%;">
	       	 		<sec:authorize url='/audit_init_export_current.do'>
                    <a class="mini-button" iconCls="icon-download" onclick="exportCurrent()">导出当前</a>
                    </sec:authorize>
                    <sec:authorize url='/audit_init_export_all.do'>
                    <a class="mini-button" iconCls="icon-download" onclick="exportAll()">导出全部</a>
                    </sec:authorize>
                </td>
	        </tr>
       	</table>
     </div>
     <div class="mini-fit" >
     <div id="datagrid1" class="mini-datagrid" allowCellWrap="true" idField="id" pageSize="20" url="audit_view.do" onlyCheckSelection="true" style="width:100%; height:100%;">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div width="70" headerAlign="center" align="center" renderer="ordersDetail">打开订单</div>
			<div field="serialNum" width="60" headerAlign="center" align="center" >编号</div>
			<div field="cusSerName" width="60" headerAlign="center" align="center" >客服代表</div>
			<div field="createTime" width="100" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">下单时间</div>
			<div field="name" width="50" headerAlign="center" align="center" >收货人</div>
			<div field="pName" width="50" headerAlign="center" align="center" >省</div>
			<div field="cName" width="50" headerAlign="center" align="center" >市</div>
			<div field="dName" width="50" headerAlign="center" align="center" >区</div>
			<div field="address" width="150" headerAlign="center" align="center" >发货地址</div>
			<div field="payment" width="60" headerAlign="center" align="center" >货款金额</div>
			<div field="freight" width="50" headerAlign="center" align="center" >运费</div>
			<div field="mediaName" width="100" headerAlign="center" align="center" >媒体</div>
		</div>
	</div>
	</div>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.load();
	
	//订单信息查询
	function search() {
	    var serialNum = mini.get("serialNum").getValue();
	    var expressId = mini.get("expressId").getValue();
	    var name = mini.get("name").getValue();
	    var c = mini.get("createTime").getFormValue();
	    
	    grid.load({ serialNum: serialNum,
	    	expressId: expressId,
	    	name: name,
	    	createTime: c,
	    });
	}
	
    function ordersDetail(e){
    	var record = e.record;
    	return '<a style="width:150px;" href="javascript: ordersView('+record._uid+')">查看订单</a>';
    }
    
    function ordersView(row_uid) {
    	var row = grid.getRowByUID(row_uid);
        mini.open({
            url: "audit_orders_detail_init.do?id=" + row.id,
            title: "查看订单", width: 850, height: 650,
            allowResize: false,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { row: row, type: 1 };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
            	if(action == "audit"){
            		mini.showMessageBox({
    	                title: "提示",
    	                showModal:false,
    	                iconCls: "mini-messagebox-info",
    	                message: "审核成功！",
    	                timeout: 3000,
    	                x: 'right',
    	                y: 'bottom',
    	            });
                	grid.reload();
	        	}
            }
        });
    }
	
	//导出当前
	function exportCurrent(){
	 	var data = grid.data;
        var ids = [];
        $.each(data , function(){
            ids.push(this.id);
        });
        var id = ids.join(',');
        location.href="audit_init_export_current.do?ids=" +id;
	}
	
	//导出所有
	function exportAll(){
		location.href="audit_init_export_all.do";
	}
	
</script>
</body>
</html>